package org.hxyjs.controller;

import org.hxyjs.dto.DTO;
import org.hxyjs.entity.Orderdetails;
import org.hxyjs.entity.Orderdetails;
import org.hxyjs.page.PageInfo;
import org.hxyjs.service.OrderdetailsService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@CrossOrigin
@Controller
@RequestMapping("/orderdetailsController")
public class OrderdetailsController {
	@Resource
	OrderdetailsService orderdetailsService;
	@RequestMapping("/getAllOrderdetails")
	@ResponseBody //把方法的返回值按json转换之后 输出到浏览器
    public DTO<Orderdetails> getAllOrderdetails() throws Exception {
    	System.out.println("查询全部订单详情");
		return orderdetailsService.getAllOrderdetailss();
    }

	@RequestMapping("/deleteOrderdetailsByOdno/{odno}")
	@ResponseBody
    public DTO<Orderdetails> deleteOrderdetailsByOdno(@PathVariable("odno") String odno) throws Exception {//如何从页面传入参数到方法 用这个注解绑定变量@PathVariable
    	System.out.println(odno+"删除订单详情");
    	return orderdetailsService.deleteOrderdetailsByOdno(odno);
    }

	@RequestMapping("/updateOrderdetailsByOdno")
	@ResponseBody
	public DTO<Orderdetails> updateOrderdetailsByOdno(@RequestBody Orderdetails orderdetails) throws Exception {//如何从页面传入参数到方法 用这个注解绑定变量@PathVariable
		System.out.println("修改订单详情");
		return orderdetailsService.updateOrderdetailsByOdno(orderdetails);
	}


	@RequestMapping("/addOrderdetails")
	@ResponseBody
	public DTO<Orderdetails> addOrderdetails(@RequestBody Orderdetails orderdetails) throws Exception {//如何从页面传入参数到方法 用这个注解绑定变量@PathVariable
		System.out.println("增加订单详情");
		System.out.println(orderdetails);
 		return orderdetailsService.addOrderdetails(orderdetails);
	}
	@RequestMapping("/getOrderdetailsByPage")
	@ResponseBody
	public DTO<Orderdetails> getOrderdetailsByPage(PageInfo pageInfo) throws Exception{//如何从页面传入参数到方法 用这个注解绑定变量@PathVariable
		System.out.println("分页订单详情");
		return orderdetailsService.getOrderdetailsByPage(pageInfo);
	}

}